package com.xuecheng.content.api;

import com.xuecheng.content.model.dto.TeacherCourseDto;
import com.xuecheng.content.model.po.CourseTeacher;
import com.xuecheng.content.service.CourseTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class CourseTeacherController {

    @Autowired
    private CourseTeacherService courseTeacherService;


    /**
     * 获取课程的教师列表
     * @param id
     * @return
     */
    @GetMapping("/courseTeacher/list/{id}")
    public List<CourseTeacher> list(@PathVariable Long id) {

        List<CourseTeacher> courseTeacher =  courseTeacherService.teacherList(id);

        return courseTeacher;
    }


    @PostMapping("/courseTeacher")
    public CourseTeacher createOrUpdate(@RequestBody CourseTeacher courseTeacher) {
      CourseTeacher res =  courseTeacherService.addOrUpdateTeacher(courseTeacher);
      return res;
    }


    @DeleteMapping("/courseTeacher/course/{courseId}/{teacherId}")
    public void delete(@PathVariable Long courseId,@PathVariable Long teacherId) {
        courseTeacherService.deleteTeacher(courseId,teacherId);
    }

}
